package com.qidian.study.util.pojo;

/**
 * @author 戴着假发的程序员
 * @company 起点编程
 * 统一的返回值结果
 */
public class VideoResponse <T>{
    private int code;
    private String msg;
    private T data;

    public static VideoResponse ok(){
        VideoResponse r = new VideoResponse();
        r.setCode(200);
        r.setMsg("OK");
        return r;
    }
    public static VideoResponse ok(String msg){
        VideoResponse r = new VideoResponse();
        r.setCode(200);
        r.setMsg(msg);
        return r;
    }

    public static VideoResponse ok(String msg,Object obj){
        VideoResponse r = new VideoResponse();
        r.setCode(200);
        r.setMsg(msg);
        r.setData(obj);
        return r;
    }

    public static VideoResponse error(int code,String msg,Object obj){
        VideoResponse r = new VideoResponse();
        r.setCode(code);
        r.setMsg(msg);
        r.setData(obj);
        return r;
    }
    public static VideoResponse error(int code,String msg){
        VideoResponse r = new VideoResponse();
        r.setCode(code);
        r.setMsg(msg);
        return r;
    }
    public static VideoResponse error(int code){
        VideoResponse r = new VideoResponse();
        r.setCode(code);
        return r;
    }
    public static VideoResponse error(){
        VideoResponse r = new VideoResponse();
        r.setCode(500);
        return r;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
